﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Hxsoft.AppV1.Module;

namespace Hxsoft.AppV1.Admin.PageBlockManage.Controls
{
	public partial class EditPageBlock : BaseUserControl
	{
        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    this.DataBind();
        //}

		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);

			FCKeditor.BindUploadUrl(CtrlContent, GlobalID, PageBlocks.INFO_TYPE, SiteId);
		}		
		/// <summary>
		/// 属性 Name
		/// </summary>
		public string Name
		{
			get
			{
				return Convert.ToString(CtrlName.Text);
			}
			set
			{
				CtrlName.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 Content
		/// </summary>
		public string Content
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlContent.Value))
					return null;

				return Convert.ToString(CtrlContent.Value);
			}
			set
			{
				if (value == null)
					CtrlContent.Value = "";
				else
					CtrlContent.Value = value.ToString();
			}
		}


		/// <summary>
		/// 控件的 PageBlockInfo 实例。
		/// </summary>
		public Module.PageBlock Info
		{
			get
			{
				Module.PageBlock pageBlock = new Module.PageBlock();

				pageBlock.GlobalId = GlobalID;
				pageBlock.Name = Name;
				pageBlock.Content = Content;

				return pageBlock;
			}
			set
			{
				if (value == null) return;

				GlobalID = value.GlobalId;
				Name = value.Name;
				Content = value.Content;
				SiteId = value.SiteId;
			}
		}
	}
}